package com.spring.sunflower.common

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.spring.sunflower.R
import com.spring.sunflower.bean.*
import com.spring.sunflower.util.DateTimeUtils
import java.util.*

/**
 * Created by Kevin on 2021/8/28<br/>
 *
 * Describe:<br/>
 */
class BillDetailAdapter(layoutResId: Int, data: MutableList<BillBean.DatasBean>) :
    BaseQuickAdapter<BillBean.DatasBean, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: BillBean.DatasBean) {
        when (item.type) {
            "2" -> {//视频聊天
                holder.setText(
                    R.id.tvTitle,
                    "与${item.nickname}${item.detail}"
                )
            }
            "3" -> {//礼物
                holder.setText(
                    R.id.tvTitle,
                    "赠送${item.nickname}${item.detail}"
                )
            }
            "5" -> {//iM
                holder.setText(
                    R.id.tvTitle,
                    "与${item.nickname}聊天"
                )
            }
        }
        val timeFormatText = DateTimeUtils.getTimeFormatText(Date((item.createTime).toLong()))
        holder.setText(R.id.tvTime, timeFormatText)
        val tvDetail = holder.getView<TextView>(R.id.tvDetail)
        if ((item.goldCoin).toInt() >= 0) {
            tvDetail.setText("+${item.goldCoin}")
            tvDetail.setTextColor(ContextCompat.getColor(context, R.color.colorPrimary))
        } else {
            tvDetail.setText("${item.goldCoin}")
            tvDetail.setTextColor(ContextCompat.getColor(context, R.color.green))
        }


//        val ivMoney: ImageView = holder.getView(R.id.ivMoney)
//        ivMoney.setImageResource(R.drawable.ic_income_diamond)

    }
}